import pymongo
client = pymongo.MongoClient("mongodb://localhost:27017/")
db = client.Advanced
collection = db.Test
for item in collection.find():
    if not item["href"]:
        collection.delete_one(item)
    if not item["text"]:
        collection.delete_one(item)